home *** CD-ROM | disk | FTP | other *** search
- /* Modified excerpt of Journal to demo using RexxIntuition library */
- /* Set your editor's TAB width to 3 */
-
- /* ----- Get today's date (using CLI Date command) into our 3 variables ---- */
- address command('date to ram:date')
- open('dat','ram:date','R')
- seek('dat',0,'B')
- spec = readln('dat')
- parse var spec day date time
- close('dat')
- spec = ' Journal entry for 'date
- path = date
- trace results
-
- /* ----- Open the screen/window (defaults) for Journal, attach menu ---- */
- screen = rxi_GetScreen(spec,,,,,,2)
- window = rxi_GetWindow(spec,screen,,,,,,64+256+512+8,4096+2048+256)
- menu = rxi_AddMenu(window,'Project',1,)
- item = rxi_AddItem(menu,'Make Entry ',4,,,'M',window)
- item = rxi_AddItem(menu,'Read Entry ',4,,,'R',window)
- item = rxi_AddItem(menu,'Delete Entry',4,,,'D',window)
- item = rxi_AddItem(menu,'New ',4,,,'N',window)
- item = rxi_AddItem(menu,'Quit ',4,,128,'Q',window)
-
- /* ---- Add string gadgets for each line of the Journal (actually, a ---- */
- /* ---- text editor that can interact with an ARexx script such as ---- */
- /* ---- dissidents disEd would be best (plug). ---- */
-
- err = rxi_SetDraw(window,0,0,0) /* So that string gadget borders are invisible */
- width = rxi_PEEK(window,8,1) /* Get window's width */
- numChars = (width-8)/8
- numLines = rxi_PEEK(window,10,1) /* Get window's height */
- numLines = ((numLines-10)/10)-1
- err = 0
- do i = 0 to numLines
- yoffset = 10 + (10*i)
- gadg = rxi_AddGadg(window,4,,,yoffset,width,10,1,i,2,numChars)
- if err = 0 then do
- gadglist = gadg /* Save the address of our first str gadget for later */
- err = 1
- end
- end
- err = rxi_SetDraw(window,1,0,1) /* reset to defaults */
-
- /* ---- Get a ReqDef for file requester ---- */
- reqdef = rxi_GetReq()
-
- /* ---- Do our IDCMP loop ---- */
- class = 1
- do while class > 0
- spec = rxi_WaitMsg(window)
- parse var spec class part1 part2 part3
- if class = 2 then do
- if part2 = 0 then do
- call MakeEntry
- end
- if part2 = 1 then do
- call ReadEntry
- end
- if part2 = 2 then do
- call DeleteEntry
- end
- if part2 = 3 then do
- call NewEntry
- end
- end
- end
-
- /* ----- Close window and screen, and exit ----- */
- ending:
- reqdef = rxi_EndReq(reqdef)
- window = rxi_EndWindow(window)
- screen = rxi_EndScreen(screen)
- exit 0
-
- /* ------ Saves the contents of string gadgets into the Journal file ------- */
- MakeEntry:
- /* Get journal filename */
- path = rxi_ReqNW(reqDef,'Save Journal File:',8192,,'.JLE',date,,,window,-1,-1)
- if path > '' then do
- err = rxi_Peek(reqdef,4,0)
- if err > 0 then do
- /* See if the file exists, and if so, ask about appending */
- err = rxi_Peek(reqdef,204,2)
- if err > 0 then do
- err = rxi_MsgThree(window,'The Journal File',path,'exists. Append it?')
- if err = 0 then return('')
- err = rxi_Title(window,reqdef,'Appending to existing entry...',)
- open('jnl',path,'A')
- end
- if err = 0 then do
- err = rxi_Title(window,reqdef,'Creating new entry...',)
- open('jnl',date'.JLE','W')
- /* Here, we should write out some heading to the file. I removed that */
- close ('jnl')
- open('jnl',date'.JLE','A')
- end
- call LineLoop
- end
- end
- return('')
-
- LineLoop:
- do i = 0 to numLines
- Entri = rxi_GInfo(window,i)
- writeln('jnl',Entri)
- end i
- close('jnl')
- err = rxi_Title(window,reqdef,'Saved OK',)
- return('')
-
- /* ---------- Reads the Journal file into the string gadgets ----------- */
- ReadEntry:
- /* Get journal filename */
- path = rxi_ReqNW(reqDef,'Read Journal File:',8192,,'.JLE',path,,,window,-1,-1)
- if path > '' then do
- err = rxi_Peek(reqdef,4,0)
- if err > 0 then do
- /* See if the file exists, and if so, load it into string gadgets */
- err = rxi_Peek(reqdef,204,2)
- if err > 0 then do
- open('jnlR',path,'R')
- err = rxi_Title(window,reqdef,' Reading journal... ',)
- seek('jnlR',0,'B')
- Entri=readln('jnlR')
- err = rxi_ModIDCMP(window,,,65536) /* Trap right mouse button */
- do until EOF('jnlR')
- gadg = gadglist
- do i = 0 to numLines
- gadg = rxi_ModGadg(window,gadg,,,,Entri,,,,,)
- gadg = rxi_PEEK(gadg,0,2) /* Get next gadget */
- Entri=readln('jnlR')
- end i
- if ~EOF('jnlR') then do
- err = rxi_Title(window,reqdef,' Click menu button for more ',)
- do while class < 3
- spec = rxi_WaitMsg(window)
- parse var spec class part1
- end
- end
- end
- err = rxi_Title(window,reqdef,' Journal entry for ',path)
- err = rxi_ModIDCMP(window,,,4096) /* Free right mouse button */
- close('jnlR')
- end
- else
- err = rxi_Title(window,reqdef,'Cannot find ',path)
- end
- end
- return('')
-
- /* ------------ Deletes a Journal File ----------------- */
- DeleteEntry:
- path = rxi_ReqNW(reqDef,'Delete Journal File:',8192,,'.JLE',date,,,window,-1,-1)
- if path > '' then do
- err = rxi_Peek(reqdef,4,0)
- if err > 0 then do
- /* See if the file exists, and if so, delete it. */
- err = rxi_Peek(reqdef,204,2)
- if err > 0 then do
- err = rxi_MsgOne(window,'Delete this entry?')
- if err = 1 then do
- address command('delete 'path)
- err = rxi_Title(window,reqdef,'Deleted ',path)
- end
- end
- else
- err = rxi_Title(window,reqdef,,)
- end
- end
- return('')
-
- /* ------ Clears out the text in the string gadgets ------- */
- NewEntry:
- err = rxi_Title(window,reqdef,,)
- gadg = gadglist
- do i = 0 to numLines
- gadg = rxi_ModGadg(window,gadg,,,,'',,,,,)
- gadg = rxi_PEEK(gadg,0,2)
- end i
- return('')
-